package com.lin.missyou.model;

import com.lin.missyou.dto.SkuInfoDTO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

/**
 *
 * @author gcq
 * @Create 2021-11-12
 */
@Getter
@Setter
@NoArgsConstructor
public class OrderSku {
    private Long id;
    /**
     * 当前sku对应的spuId
     */
    private Long spuId;
    /**
     * 购买数量 * 单价 总价格
     */
    private BigDecimal finalPrice;
    /**
     * 商品单价
     **/
    private BigDecimal singlePrice;
    /**
     * 规格
     */
    private List<String> specValues;
    /**
     * 数量
     */
    private Integer count;
    /**
     * 图片
     */
    private String img;
    /**
     * 标题
     */
    private String title;

    public OrderSku(SkuInfoDTO skuInfoDTO, Sku sku) {
        this.id = sku.getId();
        this.spuId = sku.getSpuId();
        this.singlePrice = sku.getActualPrice();
        //
        this.finalPrice = sku.getActualPrice().multiply(new BigDecimal(sku.getStock()));
        this.count = skuInfoDTO.getCount();
        this.img = sku.getImg();
        this.title = sku.getTitle();
        this.specValues = sku.getSpecValueList();
    }
}